const express = require('express')
const server = express()

server.use(express.urlencoded({ extended: false }))
server.use(express.json())
server.use('/api', require('./src/api_news'))

// 分页接口
// server.get('/getStuPage', async (request, response, next) => {
//   let pageSize =
//     request.query.pageSize == undefined ? 5 : request.query.pageSize
//   let pageIndex =
//     request.query.pageIndex == undefined ? 1 : request.query.pageIndex

//   let sql = 'SELECT * FROM students LIMIT ?,? ;'
//   let params = [(pageIndex - 1) * parseInt(pageSize), parseInt(pageSize)]
//   let result = await db.query(sql, params)
//   response.json({
//     code: 200,
//     data: result,
//     msg: '查询成功'
//   })
// })

server.listen(8080, () => {
  console.log('服务器启动完毕')
})
